package Logic;

import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;

import javax.swing.JOptionPane;

import Messages.*;
import ocsf.server.ConnectionToClient;
/**
 * this class runing the main tra
 * @author Ron Shenkerman
 * @author Gabi Revah
 * @author Aviad Almog
 * @author Ivan Onyshchenko
 */
public class TaskAssignment {

 ConnectionToClient client;
 
	public TaskAssignment(Object msg, ConnectionToClient client) throws SQLException, IOException{

		  
		  @SuppressWarnings("unchecked")
		ArrayList<Object> str = (ArrayList<Object>)msg;
		  
	//  System.out.println("Task");

		//  msg= msg.toString().substring(1, msg.toString().length()-1); // remove the [] from the msg by substring 
		 // str = msg.toString().split("[ , ] "); // remove the , from msg and spliting it to tiny str array parts  
		
	//	  System.out.println(str[0]);
	//	  System.out.println(str[1]);             // test prints 
	//	  System.out.println(str[2]);
		  
		 
		  
	      switch((String)str.get(0))
	      {          
			      case ("Login"):
				  {
					
			    	  MessageLogin login =  new MessageLogin(str, client);  
			    	  login.Autorization();
					  
			      break;
				  }
			      
			      case ("Logout"):
			      {
			    		
			    	  MessageLogout ml =  new MessageLogout(str, client);  
			    	  ml.Logout((String)str.get(1),(String)str.get(2));
			    	  break;
			      }
			      
			      case ("Bank"):
			      {
			    		
			    	  MessageBank b =  new MessageBank(str, client);  
			    	  b.Bank();
			    	  break;
			      }
			      
			      case ("Center"):
			      {
			    		
			    	  MessageCenter c =  new MessageCenter(str, client);  
			    	  c.Center();
			    	  break;
			      }
			      
			      case ("Run"):
			      {
			    		
			    	  MessageRun r =  new MessageRun(str, client);  
			    	  r.Run((String)str.get(1),(String)str.get(2),(String)str.get(3));
			    	  break;
			      }
			      
			      case ("LoadStep"):
			      {
			    		
			    	  MessageLoadStep ls =  new MessageLoadStep(str, client);  
			    	  ls.Load((String)str.get(1),(String)str.get(2));
			    	  break;
			      }
			      case ("PassStep"):
			      {
			    		
			    	  MessagePassStep ps =  new MessagePassStep(str, client);  
			    	  ps.Load((String)str.get(1),(String)str.get(2),(String)str.get(3),(String)str.get(4));
			    	  break;
			      }
			      
			      case ("FailStep"):
			      {
			    		
			    	  MessageFailStep fs =  new MessageFailStep(str, client);  
			    	  fs.Load((String)str.get(1),(String)str.get(2),(String)str.get(3),(String)str.get(4));
			    	  break;
			      }
			      case ("UnknowStep"):
			      {
			    		
			    	  MessageUnknowStep us =  new MessageUnknowStep(str, client);  
			    	  us.Load((String)str.get(1),(String)str.get(2),(String)str.get(3),(String)str.get(4));
			    	  break;
			      }
			      case ("AddScenario"):
			      {
			    		
			    	  MessageAddScenario as =  new MessageAddScenario(str, client);  
			    	  as.Run((String)str.get(1),(String)str.get(2),(String)str.get(3));
			    	  break;
			      }
			      case ("SaveStep"):
			      {
			    		
			    	  MessageSaveStep as =  new MessageSaveStep(str, client);  
			    	  as.Run((String)str.get(1),(String)str.get(2),(String)str.get(3),(String)str.get(4),(String)str.get(5),(String)str.get(6));
			    	  break;
			      }
			      case ("StopScenario"):
			      {
			    		
			    	  MessageStopScenario as =  new MessageStopScenario(str, client);  
			    	  as.Run((String)str.get(1));
			    	  break;
			      }
			      case ("ContinueStep"):
			      {
			    		
			    	  MessageContinueStep cs =  new MessageContinueStep(str, client);  
			    	  cs.Run((String)str.get(1));
			    	  break;
			      }
			      case ("DeleteRun"):
			      {
			    		
			    	  MessageDeleteRun dr =  new MessageDeleteRun(str, client);  
			    	  dr.Run((String)str.get(1));
			    	  break;
			      }
			      case ("DeleteScenario"):
			      {
			    		
			    	  MessageDeleteScenario ds =  new MessageDeleteScenario(str, client);  
			    	  ds.Run((String)str.get(1));
			    	  break;
			      }
			      case ("AddUser"):
			      {
			    		
			    	  MessageAddUser au =  new MessageAddUser(str, client);  
			    	  au.Run((String)str.get(1),(String)str.get(2),(String)str.get(3),(String)str.get(4));
			    	  break;
			      }
			      
			      
			      
			      
			      
	    	 
	      }
	       
	  //  default:
		//	  JOptionPane.showMessageDialog(null, "This Option isn't handeled yet!!!!",null, JOptionPane.WARNING_MESSAGE);
	    	//  break;
	     
	
  
    	  
	  }
	
}

